import Vue from 'vue'
import VueI18n from 'vue-i18n'
import locale from 'element-ui/lib/locale'
import elementEN from 'element-ui/lib/locale/lang/en' // 引入饿了么的英文包
import elementZH from 'element-ui/lib/locale/lang/zh-CN' // 引入饿了么的中文包
import selfZH from './lang/zh.js'
import selfEN from './lang/en.js'
import Cookie from 'js-cookie'

// 注册
Vue.use(VueI18n)

const i18n = new VueI18n({
  locale: Cookie.get('hr-lang') || 'zh',
  messages: {
    zh: {
      ...elementZH, ...selfZH
    },
    en: {
      ...elementEN, ...selfEN
    }
  }
})
locale.i18n((key, value) => i18n.t(key, value))

export default i18n
